﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace GiaoDien
{
    public partial class WebForm13 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["DangNhap"] != null)
            {
                if (IsPostBack == false)
                {
                    ServiceKD.KhachHang kh = (ServiceKD.KhachHang)Session["DangNhap"];
                    txtTenTaiKhoan.Text = kh.tenDangNhap;
                    txtMatKhau.Text = kh.matKhau;
                    txtEmail.Text = kh.email;
                    txtGoLaiMatKhau.Text = kh.matKhau;
                    txtDienThoai.Text = kh.soDienThoai;
                    txtMaTaiKhoanNganHang.Text = kh.maTaiKhoanNghanHang + "";
                    txtDiaChi.Text = kh.diaChi;
                    txtTenKhachHang.Text = kh.tenKhachHang;
                }
            }
            else
                Response.Redirect("ListSanPham.aspx");
        }

        protected void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (Session["DangNhap"] != null)
            {
                ServiceKD.KhachHang kh = (ServiceKD.KhachHang)Session["DangNhap"];
                if (txtTenKhachHang.Text != "")
                    kh.tenKhachHang = txtTenKhachHang.Text;
                if (txtMatKhau.Text != "")
                    kh.matKhau = txtMatKhau.Text;
                if (txtDienThoai.Text != "")
                    kh.soDienThoai = txtDienThoai.Text;
                if (txtDiaChi.Text != "")
                    kh.diaChi = txtDiaChi.Text;
                if (txtMaTaiKhoanNganHang.Text != "")
                    kh.maTaiKhoanNghanHang = Int32.Parse(txtMaTaiKhoanNganHang.Text);


                ServiceKD.ServiceSoapClient proxy = new GiaoDien.ServiceKD.ServiceSoapClient("ServiceSoap");
                bool kq = proxy.capNhatThongTinTaiKhoan(kh);
                if (kq)
                    lblThongBao.Text = "Cập nhật thành công!";
                else
                    lblThongBao.Text = "Cập nhật thất bại!";
            }
        }
    }
}
